{template 'common/header'}
<link type="text/css" rel="stylesheet" href="./addons/tiger_jifenbao/css/base.css" />
<ul class="nav nav-tabs">
	<li {if $operation == 'post'}class="active"{/if}><a href="{php echo $this->createWebUrl('ad', array('op' => 'post'));}">添加</a></li>
	<li {if $operation == 'display'}class="active"{/if}><a href="{php echo $this->createWebUrl('ad', array('op' => 'display'));}">管理</a></li>
</ul>
{if $operation == 'post'}

<div class="panel panel-default">
   <div class="panel-heading">
      <h3 class="panel-title">
       编辑广告
      </h3>
   </div>
   <div class="panel-body">
        <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
          <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">名称</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" name="title" value="{$item['title']}"  placeholder="名称">
            </div>
          </div>
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">图片</label>
            <div class="col-sm-10">
              {php echo tpl_form_field_image('pic',$item['pic'])}
            </div>
          </div> 
          <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">网址</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" name="url" value="{$item['url']}"  placeholder="http://">
            </div>
          </div>                   
          <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
               <input type="hidden" name="id" value="{$item['id']}" />
               <input type="submit" name="submit" class="btn btn-default" value="提交"  class="btn btn-primary"/>
               <input type="hidden" name="token" value="{$_W['token']}" />
            </div>
          </div>
        </form>
   </div>
</div>


<script language='javascript'>
  require(['jquery', 'util'], function($, u){
    $(function(){
      $('.richtext-clone').each( function() {
        u.editor(this);
      });
    });
  });
</script>

{elseif $operation == 'display'}
<div class="panel panel-default">
      <table class="table">
          <th>名称</th>
          <th>图片</th>
          <th>网址</th>
          <th  style="text-align:right;">操作</th>

      {loop $list $item}
        <tr>
          <td>{$item['title']}</td>
          <td><img src="/attachment/{$item['pic']}" height='100'/></td>
          <td>{$item['url']}</td>
          <td style="text-align:right;">
            <a href="{php echo $this->createWebUrl('ad', array('id' => $item['id'], 'op' => 'post'))}" title="编辑" class="btn btn-sm btn-primary"><i class="fa fa-edit"></i>编辑</a>
            <a href="{php echo $this->createWebUrl('ad', array('id' => $item['id'], 'op' => 'delete'))}" onclick="return confirm('此操作不可恢复，确认删除？');return false;" title="删除" class="btn btn-sm btn-default"><i class="fa fa-remove"></i>删除</a>
          </td>
        </tr>
        {/loop}
       </table>
 
</div>
{/if}

<script>
require(['jquery', 'util'], function($, u){
	$(function(){ $('.richtext-clone').each( function() { u.editor(this); });		});
  $('.btn').hover(function(){$(this).tooltip('show');},function(){$(this).tooltip('hide');});
  $('.full').hover(function(){$(this).tooltip('show');},function(){$(this).tooltip('hide');});
});
</script>


{template 'common/footer'}
